package mysql

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Phone    string `gorm:"type:varchar(11);not null;comment:'手机号'"`
	Password string `gorm:"type:varchar(32);not null;comment:'密码'"`
}

func (c *User) GetUser(phone string) (result User, err error) {
	DB.Debug().Where("phone = ?", phone).Limit(1).Find(&result)
	return
}

func (c *User) Create(user User) error {
	return DB.Debug().Create(&user).Error
}

func (c *User) ListUser() (result []*User, err2 error) {
	DB.Debug().Find(&result)
	return
}
